package cn.edu.answer.service.impl;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import cn.edu.answer.dao.TeacherDao;
import cn.edu.answer.po.Teacher;
import cn.edu.answer.service.TeacherService;
import cn.edu.answer.utils.Page;

@Service("teacherService")
public class TeacherServiceImpl implements TeacherService {

	@Autowired
	private TeacherDao teacherDao;
	
	@Override
	public Page<Teacher> findTeacherList(Integer page, Integer rows) {
		// 创建教师对象
		Teacher teacher = new Teacher();

				// 当前页
		teacher.setStart((page-1) * rows) ;
				// 每页数
		teacher.setRows(rows);
				// 查询教师列表
				List<Teacher> teachers = 
						teacherDao.selectTeacherList(teacher);
				// 查询教师列表总记录数
				Integer count = teacherDao.selectTeacherListCount(teacher);
				// 创建Page返回对象
				Page<Teacher> result = new Page<>();
				result.setPage(page);
				result.setRows(teachers);
				result.setSize(rows);
				result.setTotal(count);
				return result;
	}

	@Override
	public int deleteTeacher(String tno) {
		// TODO Auto-generated method stub
		return teacherDao.deleteTeacher(tno);
	}

}
